using System;
using System.IO;
using System.Net.NetworkInformation;

// 产品类
public class Product
{
    public string PartA { get; private set; }
    public string PartB { get; private set; }
    public string PartC { get; private set; }

    public void AddPartA(string partA)
    {
        PartA = partA;
    }

    public void AddPartB(string partB)
    {
        PartB = partB;
    }

    public void AddPartC(string partC)
    {
        PartC = partC;
    }

    public override string ToString()
    {
        return $"Product: {PartA}, {PartB}, {PartC}";
    }
}

// 抽象建造者
public abstract class Builder
{
    public abstract void BuildPartA();
    public abstract void BuildPartB();
    public abstract void BuildPartC();
    public abstract Product GetResult();
}

// 具体建造者
public class ConcreteBuilder : Builder
{
    private Product _product = new Product();

    public override void BuildPartA()
    {
        _product.AddPartA("PartA");
    }

    public override void BuildPartB()
    {
        _product.AddPartB("PartB");
    }

    public override void BuildPartC()
    {
        _product.AddPartC("PartC");
    }

    public override Product GetResult()
    {
        return _product;
    }
}

// 指挥者
public class Director
{
    private Builder _builder;

    public Director(Builder builder)
    {
        _builder = builder;
    }

    public Product Construct()
    {
        _builder.BuildPartA();
        _builder.BuildPartB();
        _builder.BuildPartC();
        return _builder.GetResult();
    }
}

// 客户端代码
class Program
{
    static void Main(string[] args)
    {
        Director director = new Director(new ConcreteBuilder());
        Product product = director.Construct();
        Console.WriteLine(product);
    }
}

//输出结果： Product: PartA, PartB, PartC